function obj = A1b_mc(mc_opt, mc, i, market_id_k, Y_k, prodsMarket, EstShare_true, marketStarts, marketEnds, price_k, expenditure_k_market, f_opt, alpha_price, alpha_1, simShare_true, nn)

t = market_id_k(i,1);
i0 = marketStarts(t,1) - 1;
mc(i - i0,1) = mc_opt;    
Y_market = Y_k(t,:);
Y_market = repmat(Y_market, prodsMarket(t,1), 1);
N_j = EstShare_true(marketStarts(t,1):marketEnds(t,1),1) .* (price_k(marketStarts(t,1):marketEnds(t,1),1) - mc) ./ price_k(marketStarts(t,1):marketEnds(t,1),1) .* expenditure_k_market/f_opt;
alpha_i = alpha_price + alpha_1*Y_market;
sum_alpha_s = alpha_i.*simShare_true(marketStarts(t,1):marketEnds(t,1),:);
sum_alpha_s2 = alpha_i.*(simShare_true(marketStarts(t,1):marketEnds(t,1),:).^2);
obj_all = EstShare_true(marketStarts(t,1):marketEnds(t,1),1)./N_j .* mc + (price_k(marketStarts(t,1):marketEnds(t,1),1) - mc) .* (1/nn) .* [sum(sum_alpha_s,2)./N_j - sum(sum_alpha_s2,2)./(N_j.^2)];   
obj = obj_all(i-i0,1);

end

